package com.practice.springboot_01_zwj.controller;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.practice.springboot_01_zwj.entity.dto.MainTaskWithSubTasksDTO;
import com.practice.springboot_01_zwj.entity.dto.TaskAllQueryRequest;
import com.practice.springboot_01_zwj.entity.*;
import com.practice.springboot_01_zwj.mapper.AccountInfoMapper;
import com.practice.springboot_01_zwj.mapper.SubTaskMapper;
import com.practice.springboot_01_zwj.service.BatchSubTaskService;
import com.practice.springboot_01_zwj.service.TaskExportService;
import com.practice.springboot_01_zwj.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.*;

@RestController
@RequestMapping("/api/tasks")
public class TaskController {

    @Autowired
    private TaskService taskService;
    @Autowired
    private SubTaskMapper subTaskMapper;

    @Autowired
    private AccountInfoMapper accountMapper;
    @Autowired
    private BatchSubTaskService batchSubTaskService; // 新增批量子任务服务
    @Autowired
    private TaskExportService taskExportService;


    // 统一的响应结构
    private Map<String, Object> buildResponse(int code, String message, Object data) {
        Map<String, Object> response = new HashMap<>();
        response.put("code", code);
        response.put("message", message);
        if (data != null) response.put("data", data);
        return response;
    }
    //默认查询（目标管理主任务接口）
    @PostMapping("/selectTasks")
    public ResponseEntity<?> queryMainTasks(@RequestBody TaskQueryRequest request) {
        try {
            // 验证必填字段：当taskType不是'70'时，派发人不能为空
            if (!"70".equals(request.getTaskType()) && (request.getDistributor() == null || request.getDistributor().isEmpty())) {
                return ResponseEntity.status(400).body(buildResponse(400, "派发人不能为空", null));
            }

            // 验证分页参数
            if (request.getPage() < 1) {
                return ResponseEntity.status(400).body(buildResponse(400, "页码必须大于0", null));
            }

            if (request.getSize() < 1 || request.getSize() > 100) {
                return ResponseEntity.status(400).body(buildResponse(400, "分页大小必须在1-100之间", null));
            }

            Map<String, Object> result = taskService.getMainTasksByDistributor(
                    request.getDistributor(),
                    request.getMainName(),
                    request.getExecutor(),
                    request.getTaskState(),
                    request.getTaskType(),
                    request.getDeptName(),
                    request.getPage(),
                    request.getSize()
            );

            return ResponseEntity.ok(buildResponse(200, "查询成功", result));
        } catch (Exception e) {
            return ResponseEntity.status(500).body(
                    buildResponse(500, "查询失败: " + e.getMessage(), null)
            );
        }
    }
    // 创建任务（主任务）
    @PostMapping
    public ResponseEntity<?> createMainTask(@RequestBody MainTaskRequest request) {
        try {
            // 验证派发人是否存在并获取userId
            AccountInfo distributorAccount = accountMapper.findByUsername(request.getDistributor());
            if (distributorAccount == null) {
                return ResponseEntity.status(400).body(buildResponse(400, "派发人不存在", null));
            }

            // 验证主任务执行人是否存在并获取地市信息
            AccountInfo executorAccount = accountMapper.findByUsername(request.getExecutor());
            if (executorAccount == null) {
                return ResponseEntity.status(400).body(buildResponse(400, "主任务执行人不存在", null));
            }

            MainTask mainTask = new MainTask();
            mainTask.setMainName(request.getMainName());
            mainTask.setMainDescription(request.getMainDescription());
            mainTask.setDistributor(request.getDistributor());
            mainTask.setExecutor(request.getExecutor());
            mainTask.setBelonging(executorAccount.getCityName()); // 归属地市
            mainTask.setPhone(request.getPhone());
            mainTask.setPlanBeginTime(request.getPlanBeginTime());
            mainTask.setPlanEndTime(request.getPlanEndTime());
            mainTask.setUserId(distributorAccount.getUserId());
            mainTask.setTaskType(request.getTaskType());
            mainTask.setSpecializedName(request.getSpecializedName());
            mainTask.setDeptName(request.getDeptName());

            // 确保设置默认值
            mainTask.setTaskState(0);
            mainTask.setTaskProgress(0.0);
            mainTask.setTimeProgress(0.0);
            mainTask.setTaskImplementation("落后");

            // 只创建主任务，不处理子任务
            Integer mainId = taskService.createMainTask(mainTask);
            return ResponseEntity.ok(buildResponse(200, "主任务创建成功", mainId));
        } catch (IllegalArgumentException e) {
            return ResponseEntity.status(400).body(buildResponse(400, e.getMessage(), null));
        } catch (Exception e) {
            return ResponseEntity.status(500).body(buildResponse(500, "主任务创建失败: " + e.getMessage(), null));
        }
    }
    //添加子任务接口
    @PostMapping("/{mainId}/subtasks")
    public ResponseEntity<?> addSubtasks(
            @PathVariable Integer mainId,
            @RequestBody List<SubTaskRequest> subTaskRequests) {

        try {
            // 1. 检查主任务是否存在
            MainTask mainTask = taskService.getTaskDetail(mainId);
            if (mainTask == null) {
                return ResponseEntity.status(400).body(buildResponse(400, "主任务不存在", null));
            }

            // 2. 验证请求数据
            if (subTaskRequests == null || subTaskRequests.isEmpty()) {
                return ResponseEntity.status(400).body(buildResponse(400, "子任务列表不能为空", null));
            }

            // 3. 验证子任务时间范围是否在主任务的时间范围内
            validateSubTaskDates(subTaskRequests, mainTask.getPlanBeginTime(), mainTask.getPlanEndTime());

            List<SubTask> subTasks = new ArrayList<>();
            for (SubTaskRequest sub : subTaskRequests) {
                // 检查执行人列表
                if (sub.getSubExecutors() == null || sub.getSubExecutors().isEmpty()) {
                    return ResponseEntity.status(400).body(buildResponse(400, "子任务执行人列表不能为空", null));
                }

                // 验证所有执行人是否存在并获取地市信息
                List<String> executorNames = new ArrayList<>();
                List<String> belongingNames = new ArrayList<>();

                for (String executor : sub.getSubExecutors()) {
                    AccountInfo subExecutorAccount = accountMapper.findByUsername(executor);
                    if (subExecutorAccount == null) {
                        return ResponseEntity.status(400).body(buildResponse(400,
                                "子任务执行人 '" + executor + "' 不存在", null));
                    }
                    executorNames.add(executor);
                    belongingNames.add(subExecutorAccount.getCityName());
                }

                // 创建单个子任务记录
                SubTask task = new SubTask();
                task.setSubName(sub.getSubName());
                task.setSubDescription(sub.getSubDescription());
                task.setPlanStartTime(sub.getPlanStartTime());
                task.setPlanFinishTime(sub.getPlanFinishTime());
                task.setFinishProgress(0.0);

                // 将多个执行人用逗号分隔存储到 subExecutor 字段
                task.setSubExecutor(String.join(",", executorNames));

                // 将多个归属组织用逗号分隔存储到 subBelonging 字段
                task.setSubBelonging(String.join(",", belongingNames));

                // 设置主任务ID
                task.setMainId(mainId);
                subTasks.add(task);
            }

            // 4. 添加子任务
            taskService.addSubtasks(mainId, subTasks);
            return ResponseEntity.ok(buildResponse(200, "子任务添加成功，共添加 " + subTasks.size() + " 个子任务", null));
        } catch (IllegalArgumentException e) {
            return ResponseEntity.status(400).body(buildResponse(400, e.getMessage(), null));
        } catch (Exception e) {
            return ResponseEntity.status(500).body(buildResponse(500, "添加子任务失败: " + e.getMessage(), null));
        }
    }

    // 子任务时间范围验证方法
    private void validateSubTaskDates(List<SubTaskRequest> subTasks, Date mainStart, Date mainEnd) {
        if (subTasks == null) return;

        for (SubTaskRequest sub : subTasks) {
            // 检查开始时间是否早于主任务开始时间
            if (sub.getPlanStartTime().before(mainStart)) {
                throw new IllegalArgumentException("子任务的开始时间不能早于主任务的开始时间");
            }

            // 检查结束时间是否晚于主任务结束时间
            if (sub.getPlanFinishTime().after(mainEnd)) {
                throw new IllegalArgumentException("子任务的结束时间不能晚于主任务的结束时间");
            }

            // 检查开始时间是否晚于结束时间
            if (sub.getPlanStartTime().after(sub.getPlanFinishTime())) {
                throw new IllegalArgumentException("子任务的开始时间不能晚于结束时间");
            }
        }
    }

    //我的目标（主任务和子任务都有执行人的查询）
    @PostMapping("/allExecutor")
    public ResponseEntity<?> getTasksByExecutor(@RequestBody TaskQueryRequest request) {
        try {
            // 验证必填字段
            if (request.getCurrentUser() == null || request.getCurrentUser().isEmpty()) {
                return ResponseEntity.status(400).body(buildResponse(400, "当前用户不能为空", null));
            }

            // 验证分页参数
            if (request.getPage() < 1) {
                return ResponseEntity.status(400).body(buildResponse(400, "页码必须大于0", null));
            }

            if (request.getSize() < 1 || request.getSize() > 100) {
                return ResponseEntity.status(400).body(buildResponse(400, "分页大小必须在1-100之间", null));
            }

            Map<String, Object> result = taskService.getTasksByExecutorOrSubExecutor(
                    request.getCurrentUser(),
                    request.getMainName(),
                    request.getTaskState(),
                    request.getTaskType(),
                    request.getDeptName(),
                    request.getPage(),
                    request.getSize()
            );

            return ResponseEntity.ok(buildResponse(200, "查询成功", result));
        } catch (Exception e) {
            return ResponseEntity.status(500).body(
                    buildResponse(500, "查询失败: " + e.getMessage(), null)
            );
        }
    }
    // 更新主任务
    @PutMapping("/{mainId}")
    public ResponseEntity<?> updateTask(@PathVariable Integer mainId,
                                        @RequestBody MainTaskRequest request) {
        try {
            MainTask task = taskService.getTaskDetail(mainId);
            if (task == null) {
                return ResponseEntity.status(404).body(buildResponse(404, "任务不存在", null));
            }

            MainTask updateTask = new MainTask();
            updateTask.setMainId(mainId);
            updateTask.setMainName(request.getMainName());
            updateTask.setMainDescription(request.getMainDescription());
            updateTask.setExecutor(request.getExecutor());
            updateTask.setPlanBeginTime(request.getPlanBeginTime());
            updateTask.setPlanEndTime(request.getPlanEndTime());
            updateTask.setTaskState(request.getTaskState());
            updateTask.setSpecializedName(request.getSpecializedName());
            updateTask.setDeptName(request.getDeptName());

            taskService.updateMainTask(updateTask);
            return ResponseEntity.ok(buildResponse(200, "任务更新成功", null));
        } catch (IllegalStateException e) {
            return ResponseEntity.status(400).body(buildResponse(400, e.getMessage(), null));
        } catch (Exception e) {
            return ResponseEntity.status(500).body(buildResponse(500, "任务更新失败", null));
        }
    }

    // 完成任务
    @PostMapping("/{mainId}/complete")
    public ResponseEntity<?> completeTask(@PathVariable Integer mainId) {
        try {
            MainTask task = taskService.getTaskDetail(mainId);
            if (task == null) {
                return ResponseEntity.status(404).body(buildResponse(404, "目标不存在", null));
            }

            taskService.completeMainTask(task); // 传入整个任务对象
            return ResponseEntity.ok(buildResponse(200, "目标已完成", null));
        } catch (IllegalStateException e) {
            return ResponseEntity.status(200).body(buildResponse(200, e.getMessage(), null));
        } catch (Exception e) {
            return ResponseEntity.status(500).body(buildResponse(500, "目标完成失败", null));
        }
    }

    // 终止任务
    @PostMapping("/{mainId}/terminate")
    public ResponseEntity<?> terminateTask(@PathVariable Integer mainId) {
        try {
            MainTask task = taskService.getTaskDetail(mainId);
            if (task == null) {
                return ResponseEntity.status(404).body(buildResponse(404, "任务不存在", null));
            }

            taskService.terminateMainTask(mainId);
            return ResponseEntity.ok(buildResponse(200, "任务已终止", null));
        } catch (IllegalStateException e) {
            return ResponseEntity.status(400).body(buildResponse(400, e.getMessage(), null));
        } catch (Exception e) {
            return ResponseEntity.status(500).body(buildResponse(500, "任务终止失败", null));
        }
    }
    // 更新子任务接口
    @PutMapping("/subtasks/{subId}")
    public ResponseEntity<?> updateSubtask(
            @PathVariable Integer subId,
            @RequestBody SubTaskProgressRequest updateRequest) {

        try {
            // 1. 获取原子任务信息
            SubTask existingSubTask = subTaskMapper.selectById(subId);
            if (existingSubTask == null) {
                return ResponseEntity.status(400).body(buildResponse(400, "子任务不存在", null));
            }

            // 2. 验证执行人列表
            if (updateRequest.getSubExecutors() == null || updateRequest.getSubExecutors().isEmpty()) {
                return ResponseEntity.status(400).body(buildResponse(400, "子任务执行人列表不能为空", null));
            }

            // 3. 验证所有执行人是否存在并获取地市信息
            List<String> executorNames = new ArrayList<>();
            List<String> belongingNames = new ArrayList<>();

            for (String executor : updateRequest.getSubExecutors()) {
                AccountInfo subExecutorAccount = accountMapper.findByUsername(executor);
                if (subExecutorAccount == null) {
                    return ResponseEntity.status(400).body(buildResponse(400,
                            "子任务执行人 '" + executor + "' 不存在", null));
                }
                executorNames.add(executor);
                belongingNames.add(subExecutorAccount.getCityName());
            }

            // 4. 创建子任务对象
            SubTask subTask = new SubTask();
            subTask.setSubId(subId);
            subTask.setSubName(updateRequest.getSubName());
            subTask.setSubDescription(updateRequest.getSubDescription());
            subTask.setPlanStartTime(updateRequest.getPlanStartTime());
            subTask.setPlanFinishTime(updateRequest.getPlanFinishTime());
            subTask.setFinishProgress(updateRequest.getFinishProgress());

            // 设置多个执行人和归属组织
            subTask.setSubExecutors(executorNames);
            subTask.setSubBelongings(belongingNames);

            // 5. 更新子任务
            taskService.updateSubTaskProgress(subTask);

            return ResponseEntity.ok(buildResponse(200, "子任务更新成功", null));
        } catch (IllegalArgumentException e) {
            return ResponseEntity.status(400).body(buildResponse(400, e.getMessage(), null));
        } catch (Exception e) {
            return ResponseEntity.status(500).body(buildResponse(500, "更新子任务失败: " + e.getMessage(), null));
        }
    }
    // 删除子任务
    @DeleteMapping("/subtasks/{subId}")
    public ResponseEntity<?> deleteSubTask(@PathVariable Integer subId) {
        try {
            taskService.deleteSubTask(subId);
            return ResponseEntity.ok(buildResponse(200, "子任务删除成功", null));
        } catch (RuntimeException e) {
            return ResponseEntity.status(404).body(buildResponse(404, e.getMessage(), null));
        } catch (Exception e) {
            return ResponseEntity.status(500).body(buildResponse(500, "子任务删除失败: " + e.getMessage(), null));
        }
    }
    // 获取任务详情
    @GetMapping("/{mainId}")
    public ResponseEntity<?> getTaskDetail(@PathVariable Integer mainId) {
        try {
            // 实时计算进度并更新状态
            taskService.calculateAndUpdateProgress(mainId);

            MainTask task = taskService.getTaskDetail(mainId);
            if (task == null) {
                return ResponseEntity.status(404).body(buildResponse(404, "任务不存在", null));
            }

            return ResponseEntity.ok(buildResponse(200, "查询成功", task));
        } catch (Exception e) {
            return ResponseEntity.status(500).body(buildResponse(500, "查询失败: " + e.getMessage(), null));
        }
    }

    /**
     * 覆盖保存批量子任务（全量覆盖）
     * POST /api/tasks/subtasks/{subId}/batch
     */
    @PostMapping("/subtasks/{subId}/batch")
    public ResponseEntity<?> saveBatchSubTasks(
            @PathVariable Integer subId,
            @RequestBody List<BatchSubTask> tasks,
            @RequestParam String currentUser) {
        try {

            if (currentUser == null || currentUser.isEmpty()) {
                return ResponseEntity.status(400).body(buildResponse(400, "当前用户不能为空", null));
            }

            // 调用服务层处理
            Map<String, Object> result = batchSubTaskService.saveBatchSubTasks(subId, tasks, currentUser);

            return ResponseEntity.ok(buildResponse(200, "批量子任务保存成功", result));
        } catch (IllegalArgumentException e) {
            return ResponseEntity.status(400).body(buildResponse(400, e.getMessage(), null));
        } catch (Exception e) {
            return ResponseEntity.status(500).body(
                    buildResponse(500, "批量子任务保存失败: " + e.getMessage(), null)
            );
        }
    }

    /**
     * 查询批量子任务
     * GET /api/tasks/subtasks/batch/{subId}
     */
    @GetMapping("/subtasks/batch/{subId}")
    public ResponseEntity<?> getBatchSubTasks(@PathVariable Integer subId) {
        try {
            // 调用服务层查询
            List<BatchSubTask> tasks = batchSubTaskService.getBatchSubTasksBySubId(subId);

            return ResponseEntity.ok(buildResponse(200, "查询成功", tasks));
        } catch (IllegalArgumentException e) {
            return ResponseEntity.status(400).body(buildResponse(400, e.getMessage(), null));
        } catch (Exception e) {
            return ResponseEntity.status(500).body(
                    buildResponse(500, "查询失败: " + e.getMessage(), null)
            );
        }
    }

    // 获取执行人任务列表
    @GetMapping("/executor/{executor}")
    public ResponseEntity<?> getTasksByExecutor(@PathVariable String executor) {
        try {
            List<MainTask> tasks = taskService.getTasksByExecutor(executor);
            return ResponseEntity.ok(buildResponse(200, "查询成功", tasks));
        } catch (Exception e) {
            return ResponseEntity.status(500).body(buildResponse(500, "查询失败: " + e.getMessage(), null));
        }
    }

    // okr清单所有
    @PostMapping("/all")
    public ResponseEntity<?> getAllTasks(@RequestBody TaskAllQueryRequest request) {
        try {
            // 查询所有任务详情
            List<MainTaskWithSubTasksDTO> tasks = taskService.getAllTasksWithDetails(request);

            // 始终返回任务列表，即使只有一条任务
            return ResponseEntity.ok(buildResponse(200, "查询成功", tasks));
        } catch (Exception e) {
            return ResponseEntity.status(500).body(
                    buildResponse(500, "查询失败: " + e.getMessage(), null)
            );
        }
    }
    @GetMapping("/export")
    public ResponseEntity<Resource> exportTasksToExcel(TaskAllQueryRequest request) {
        try {
            Resource resource = taskExportService.exportTasks(request);

            return ResponseEntity.ok()
                    .contentType(MediaType.parseMediaType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"))
                    .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"tasks_export.xlsx\"")
                    .body(resource);
        } catch (Exception e) {
            throw new RuntimeException("导出Excel失败: " + e.getMessage(), e);
        }
    }

    //部门okr目标认领接口
    @GetMapping("/taskType/subtasks")
    public ResponseEntity<List<SubTask>> getSubtasksByMainTask(
            @RequestParam(name = "taskType", required = true) String taskType,
            @RequestParam(name = "subName", required = false) String subName) {

        List<SubTask> subTasks = taskService.findSubtasksByMainTaskType(taskType, subName);
        return ResponseEntity.ok(subTasks);
    }
    @PostMapping("/overview")
    public ResponseEntity<?> getTaskOverview(@RequestBody TaskQueryRequest request) {
        try {
            // 从请求体中获取当前用户
            String currentUser = request.getCurrentUser();

            if (currentUser == null || currentUser.isEmpty()) {
                return ResponseEntity.status(400).body(buildResponse(400, "当前用户不能为空", null));
            }

            Map<String, Object> result = taskService.getTaskOverview(currentUser);
            return ResponseEntity.ok(buildResponse(200, "查询成功", result));
        } catch (Exception e) {
            return ResponseEntity.status(500).body(
                    buildResponse(500, "查询失败: " + e.getMessage(), null)
            );
        }
    }

    /**
     * 覆盖保存批量子任务（全量覆盖）
     * POST /api/tasks/subtasks/{subId}/batch
     */
    @PostMapping("/subtasks/{subId}/batchAll")
    public ResponseEntity<?> saveBatchSubTasksAll(
            @PathVariable Integer subId,
            @RequestBody List<BatchSubTask> tasks) {
        try {
            // 调用服务层处理
            Map<String, Object> result = batchSubTaskService.saveBatchSubTasksAll(subId, tasks);

            return ResponseEntity.ok(buildResponse(200, "批量子任务保存成功", result));
        } catch (IllegalArgumentException e) {
            return ResponseEntity.status(400).body(buildResponse(400, e.getMessage(), null));
        } catch (Exception e) {
            return ResponseEntity.status(500).body(
                    buildResponse(500, "批量子任务保存失败: " + e.getMessage(), null)
            );
        }
    }

}

// 请求类
class MainTaskRequest {
    private String mainName;
    private String mainDescription;
    private String distributor;
    private String executor;
    private String belonging;
    private String phone;
    private Integer taskState;

    public Integer getTaskState() {
        return taskState;
    }

    public void setTaskState(Integer taskState) {
        this.taskState = taskState;
    }

    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date planBeginTime;
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date planEndTime;
    private String taskType;
    private String specializedName; //专项名称
    private String deptName; //科室名称

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public String getSpecializedName() {
        return specializedName;
    }

    public void setSpecializedName(String specializedName) {
        this.specializedName = specializedName;
    }

    public String getTaskType() {
        return taskType;
    }

    public void setTaskType(String taskType) {
        this.taskType = taskType;
    }

    public String getMainName() {
        return mainName;
    }

    public void setMainName(String mainName) {
        this.mainName = mainName;
    }

    public String getMainDescription() {
        return mainDescription;
    }

    public void setMainDescription(String mainDescription) {
        this.mainDescription = mainDescription;
    }

    public String getDistributor() {
        return distributor;
    }

    public void setDistributor(String distributor) {
        this.distributor = distributor;
    }

    public String getExecutor() {
        return executor;
    }

    public void setExecutor(String executor) {
        this.executor = executor;
    }

    public String getBelonging() {
        return belonging;
    }

    public void setBelonging(String belonging) {
        this.belonging = belonging;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public Date getPlanBeginTime() {
        return planBeginTime;
    }

    public void setPlanBeginTime(Date planBeginTime) {
        this.planBeginTime = planBeginTime;
    }

    public Date getPlanEndTime() {
        return planEndTime;
    }

    public void setPlanEndTime(Date planEndTime) {
        this.planEndTime = planEndTime;
    }

}
class SubTaskRequest {
    private String subName;
    private String subDescription;
    private String subExecutor;      // 子任务执行人
    private String subBelonging;     // 子任务归属组织

    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date planStartTime;
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date planFinishTime;
    private List<String> subExecutors;  // 改为列表，支持多个执行人

    public List<String> getSubExecutors() {
        return subExecutors;
    }

    public void setSubExecutors(List<String> subExecutors) {
        this.subExecutors = subExecutors;
    }

    // getters and setters
    public String getSubName() { return subName; }
    public void setSubName(String subName) { this.subName = subName; }
    public String getSubDescription() { return subDescription; }
    public void setSubDescription(String subDescription) { this.subDescription = subDescription; }

    public String getSubExecutor() {
        return subExecutor;
    }

    public void setSubExecutor(String subExecutor) {
        this.subExecutor = subExecutor;
    }

    public String getSubBelonging() {
        return subBelonging;
    }

    public void setSubBelonging(String subBelonging) {
        this.subBelonging = subBelonging;
    }

    public Date getPlanStartTime() { return planStartTime; }
    public void setPlanStartTime(Date planStartTime) { this.planStartTime = planStartTime; }
    public Date getPlanFinishTime() { return planFinishTime; }
    public void setPlanFinishTime(Date planFinishTime) { this.planFinishTime = planFinishTime; }
}
class SubTaskProgressRequest {
    private String subName;
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date planStartTime;
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date planFinishTime;
    private Double finishProgress;
    private String subExecutor;      // 可选：更新时可能需要
    private String subBelonging;     // 可选：更新时可能需要
    private List<String> subExecutors; // 多个执行人列表
    private String subDescription;

    public String getSubDescription() {
        return subDescription;
    }

    public void setSubDescription(String subDescription) {
        this.subDescription = subDescription;
    }

    public List<String> getSubExecutors() {
        return subExecutors;
    }

    public void setSubExecutors(List<String> subExecutors) {
        this.subExecutors = subExecutors;
    }

    public String getSubName() {
        return subName;
    }

    public void setSubName(String subName) {
        this.subName = subName;
    }

    public Date getPlanStartTime() {
        return planStartTime;
    }

    public void setPlanStartTime(Date planStartTime) {
        this.planStartTime = planStartTime;
    }

    public Date getPlanFinishTime() {
        return planFinishTime;
    }

    public void setPlanFinishTime(Date planFinishTime) {
        this.planFinishTime = planFinishTime;
    }

    public String getSubExecutor() {
        return subExecutor;
    }

    public void setSubExecutor(String subExecutor) {
        this.subExecutor = subExecutor;
    }

    public String getSubBelonging() {
        return subBelonging;
    }

    public void setSubBelonging(String subBelonging) {
        this.subBelonging = subBelonging;
    }

    // getters and setters

    public Double getFinishProgress() {
        return finishProgress;
    }

    public void setFinishProgress(Double finishProgress) {
        this.finishProgress = finishProgress;
    }
}
